package com.example.arithmeticleetcode.leetcode.jan;

import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2021-01-18 10:03
 **/
public class Demo13 {

    public static void main(String[] args) {

    }

    public List<List<String>> accountsMerge(List<List<String>> accounts) {
        Map<String, Integer> map = new HashMap<>();
        List<List<String>> returnList = new ArrayList<>();
        int count = 0;
        for (List<String> account : accounts) {
            int index = -1;
            for (String s : account) {
                if (map.containsKey(s)) {
                   index = map.get(s);
                }
                map.put(s, count);
            }
            count++;
            if (index == -1) {
                returnList.add(account);
            } else {
                List<String> list = returnList.get(index);

            }
        }
        return null;
    }


    /**
     * 5653. 可以形成最大正方形的矩形数目
     *
     * @param rectangles
     * @return
     */
    public int countGoodRectangles(int[][] rectangles) {
        int[] minRectangles = new int[rectangles.length];
        int maxLength = Integer.MIN_VALUE;
        for (int i = 0; i < rectangles.length; i++) {
            int min = Math.min(rectangles[i][0], rectangles[i][1]);
            minRectangles[i] = min;
            maxLength = Math.max(maxLength, min);
        }
        int count = 0;
        for (int minRectangle : minRectangles) {
            if (minRectangle == maxLength) count++;
        }
        return count;
    }
}


@Data
class Dep {
    private int id;
    private int parateId;
}